package com.zhy.springcloud.controller;

import com.zhy.springcloud.enetities.CommonResult;
import com.zhy.springcloud.entities.Payment;
import com.zhy.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author zhy
 * @Description 支付模块控制层
 * @ClassName PaymentController
 * @Date 2020/11/12 18:51
 **/
@RestController
@Slf4j
public class PaymentController {
    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @PostMapping("/payment/add")
    public CommonResult create(@RequestBody Payment payment){
        paymentService.create(payment);
        return new  CommonResult<>(200,"SUCCESS");
    }

    @GetMapping("/payment/get/{id}")
    public CommonResult getPaymentById(@PathVariable Long id){
        log.debug("SUCCESS");
        Payment paymentById = paymentService.getPaymentById(id);
        return new CommonResult(200,"SUCCESS",paymentById);
    }

    @GetMapping("/payment/lb")
    public String getPaymentLb(){
        return serverPort;
    }



}
